<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class scoped_connection</title>
<link rel="stylesheet" href="../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../signals2/reference.html#header.boost.signals2.connection_hpp" title="Header &lt;boost/signals2/connection.hpp&gt;">
<link rel="prev" href="connection.html" title="Class connection">
<link rel="next" href="deconstruct.html" title="Function deconstruct">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../boost.png"></td>
<td align="center"><a href="../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="connection.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../signals2/reference.html#header.boost.signals2.connection_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="deconstruct.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.signals2.scoped_connection"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class scoped_connection</span></h2>
<p>boost::signals2::scoped_connection — Limits a signal-slot connection lifetime to a particular scope.</p>
</div>
<h2 class="refsynopsisdiv-title">Synopsis</h2>
<div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../signals2/reference.html#header.boost.signals2.connection_hpp" title="Header &lt;boost/signals2/connection.hpp&gt;">boost/signals2/connection.hpp</a>&gt;

</span>
<span class="keyword">class</span> <a class="link" href="scoped_connection.html" title="Class scoped_connection">scoped_connection</a> <span class="special">:</span> <span class="keyword">public</span> <a class="link" href="connection.html" title="Class connection">connection</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_3-bbconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_3_1-bb"><span class="identifier">scoped_connection</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_3_2-bb"><span class="identifier">scoped_connection</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="connection.html" title="Class connection">connection</a><span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_3_3-bb"><span class="identifier">scoped_connection</span></a><span class="special">(</span><a class="link" href="scoped_connection.html" title="Class scoped_connection">scoped_connection</a><span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_3_4-bb"><span class="identifier">scoped_connection</span></a><span class="special">(</span><a class="link" href="connection.html" title="Class connection">connection</a><span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
  scoped_connection&amp; <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_3_5-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="connection.html" title="Class connection">connection</a><span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  scoped_connection&amp; <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_3_6-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><a class="link" href="scoped_connection.html" title="Class scoped_connection">scoped_connection</a><span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
  scoped_connection&amp; <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_3_7-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><a class="link" href="connection.html" title="Class connection">connection</a><span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_3_8-bb"><span class="special">~</span><span class="identifier">scoped_connection</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_3_9-bb">public methods</a></span>
  <a class="link" href="connection.html" title="Class connection">connection</a> <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_3_9_1-bb"><span class="identifier">release</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
<span class="keyword">private</span><span class="special">:</span>
  <span class="comment">// <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_4-bbconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_4_1-bb"><span class="identifier">scoped_connection</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="scoped_connection.html" title="Class scoped_connection">scoped_connection</a><span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  scoped_connection&amp; <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_4_2-bb"><span class="keyword">operator</span><span class="special">=</span></a><span class="special">(</span><span class="keyword">const</span> <a class="link" href="scoped_connection.html" title="Class scoped_connection">scoped_connection</a><span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.35.6.3.4.4"></a><h2>Description</h2>
<p>A <a class="link" href="connection.html" title="Class connection">connection</a> which automatically disconnects on destruction.</p>
<div class="section">
<div class="titlepage"><div><div><h6 class="title">
<a name="id-1.3.35.6.3.4.4.3"></a>Thread Safety</h6></div></div></div>
<p>The methods of the <code class="computeroutput">scoped_connection</code> class (including those
              inherited from its base <code class="computeroutput">connection</code> class) are thread-safe with the exception
              of <a class="link" href="connection.html#id-1_3_35_6_2_1_1_1_10_1-bb">signals2::connection::swap</a>, <a class="link" href="scoped_connection.html#id-1_3_35_6_2_1_1_2_3_9_1-bb">release</a>, and
              the assignment operator.  A <code class="computeroutput">scoped_connection</code> object
              should not be accessed concurrently when any of these operations is in progress.
              However, it is always safe to access a different <code class="computeroutput">connection</code> object
              in another thread, even if it references the same underlying signal-slot connection.
            </p>
</div>
<div class="refsect2">
<a name="id-1.3.35.6.3.4.4.4"></a><h3>
<a name="id-1_3_35_6_2_1_1_2_3-bbconstruct-copy-destruct"></a><code class="computeroutput">scoped_connection</code> public construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_35_6_2_1_1_2_3_1-bb"></a><span class="identifier">scoped_connection</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Default constructs an empty scoped_connection.</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput"><a class="link" href="connection.html#id-1_3_35_6_2_1_1_1_8_2-bb">connected</a>() == false </code></p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>Will not throw.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_35_6_2_1_1_2_3_2-bb"></a><span class="identifier">scoped_connection</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="connection.html" title="Class connection">connection</a><span class="special">&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Effects:</span></p></td>
<td><p><code class="computeroutput">this</code> references
              the connection referenced by
              <code class="computeroutput">other</code>.</p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput"><a class="link" href="connection.html#id-1_3_35_6_2_1_1_1_8_2-bb">connected</a>() == other.connected()</code></p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>Will not throw.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_35_6_2_1_1_2_3_3-bb"></a><span class="identifier">scoped_connection</span><span class="special">(</span><a class="link" href="scoped_connection.html" title="Class scoped_connection">scoped_connection</a><span class="special">&amp;&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>
<p>Move constructor.</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Effects:</span></p></td>
<td><p><code class="computeroutput">this</code> references
              the connection formerly referenced by
              <code class="computeroutput">other</code>.  The moved-from <code class="computeroutput">other</code>
              no longer references any connection.</p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>Will not throw.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_35_6_2_1_1_2_3_4-bb"></a><span class="identifier">scoped_connection</span><span class="special">(</span><a class="link" href="connection.html" title="Class connection">connection</a><span class="special">&amp;&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>
<p>Move constructor.</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Effects:</span></p></td>
<td><p><code class="computeroutput">this</code> references
              the connection formerly referenced by
              <code class="computeroutput">other</code>.  The moved-from <code class="computeroutput">other</code>
              no longer references any connection.</p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>Will not throw.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout">scoped_connection&amp; <a name="id-1_3_35_6_2_1_1_2_3_5-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="connection.html" title="Class connection">connection</a><span class="special">&amp;</span> rhs<span class="special">)</span><span class="special">;</span></pre>
<p>Copy assignment from unscoped connection.</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Effects:</span></p></td>
<td><p><code class="computeroutput">this</code> references
            the connection referenced by
            <code class="computeroutput">rhs</code>.  If <code class="computeroutput">this</code> already references another
                    connection, the old connection will be disconnected first.</p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput"><a class="link" href="connection.html#id-1_3_35_6_2_1_1_1_8_2-bb">connected</a>() == other.connected()</code></p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>Will not throw.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout">scoped_connection&amp; <a name="id-1_3_35_6_2_1_1_2_3_6-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><a class="link" href="scoped_connection.html" title="Class scoped_connection">scoped_connection</a><span class="special">&amp;&amp;</span> rhs<span class="special">)</span><span class="special">;</span></pre>
<p>Move assignment.</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Effects:</span></p></td>
<td><p><code class="computeroutput">this</code> references
            the connection formerly referenced by
            <code class="computeroutput">rhs</code>.  The moved-from <code class="computeroutput">rhs</code>
            no longer references any connection.  If <code class="computeroutput">this</code> already references another
                    connection, the old connection will be disconnected first.</p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>Will not throw.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout">scoped_connection&amp; <a name="id-1_3_35_6_2_1_1_2_3_7-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><a class="link" href="connection.html" title="Class connection">connection</a><span class="special">&amp;&amp;</span> rhs<span class="special">)</span><span class="special">;</span></pre>
<p>Move assignment.</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Effects:</span></p></td>
<td><p><code class="computeroutput">this</code> references
            the connection formerly referenced by
            <code class="computeroutput">rhs</code>.  The moved-from <code class="computeroutput">rhs</code>
            no longer references any connection.  If <code class="computeroutput">this</code> already references another
                    connection, the old connection will be disconnected first.</p></td>
</tr>
<tr>
<td><p><span class="term">Throws:</span></p></td>
<td><p>Will not throw.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_35_6_2_1_1_2_3_8-bb"></a><span class="special">~</span><span class="identifier">scoped_connection</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Effects:</span></p></td>
<td><p>If
            <code class="computeroutput">this-&gt;<a class="link" href="connection.html#id-1_3_35_6_2_1_1_1_8_2-bb">connected</a>()</code>,
            disconnects the signal-slot connection.</p></td>
</tr></tbody>
</table></div>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.35.6.3.4.4.5"></a><h3>
<a name="id-1_3_35_6_2_1_1_2_3_9-bb"></a><code class="computeroutput">scoped_connection</code> public methods</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><a class="link" href="connection.html" title="Class connection">connection</a> <a name="id-1_3_35_6_2_1_1_2_3_9_1-bb"></a><span class="identifier">release</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Effects:</span></p></td>
<td><p>
                  Releases the connection so it will not be disconnected by the <code class="computeroutput">scoped_connection</code>
                  when it is destroyed or reassigned.  The <code class="computeroutput">scoped_connection</code> is reset to
                  the NULL connection after this call completes.
                </p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p><code class="computeroutput"><a class="link" href="connection.html#id-1_3_35_6_2_1_1_1_8_2-bb">connected</a>() == false</code></p></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>A <a class="link" href="connection.html" title="Class connection">connection</a> object referencing the connection which was
                  released by the <code class="computeroutput">scoped_connection</code>.
                </p></td>
</tr>
</tbody>
</table></div>
</li></ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.35.6.3.4.4.6"></a><h3>
<a name="id-1_3_35_6_2_1_1_2_4-bbconstruct-copy-destruct"></a><code class="computeroutput">scoped_connection</code> private construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="id-1_3_35_6_2_1_1_2_4_1-bb"></a><span class="identifier">scoped_connection</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="scoped_connection.html" title="Class scoped_connection">scoped_connection</a><span class="special">&amp;</span> other<span class="special">)</span><span class="special">;</span></pre>
<p>The scoped_connection class is not copyable.  It may only be copy constructed from an unscoped
                <code class="computeroutput"><a class="link" href="connection.html" title="Class connection">connection</a></code> object.</p>
</li>
<li class="listitem">
<pre class="literallayout">scoped_connection&amp; <a name="id-1_3_35_6_2_1_1_2_4_2-bb"></a><span class="keyword">operator</span><span class="special">=</span><span class="special">(</span><span class="keyword">const</span> <a class="link" href="scoped_connection.html" title="Class scoped_connection">scoped_connection</a><span class="special">&amp;</span> rhs<span class="special">)</span><span class="special">;</span></pre>
<p>The scoped_connection class is not copyable.  It may only be copy assigned from an unscoped 
                <code class="computeroutput"><a class="link" href="connection.html" title="Class connection">connection</a></code> object.</p>
</li>
</ol></div>
</div>
</div>
</div>
<div class="copyright-footer">Copyright © 2001-2004 Douglas Gregor<br>Copyright © 2007-2009 Frank Mori Hess<p>Distributed under the Boost
    Software License, Version 1.0. (See accompanying file
    <code class="filename">LICENSE_1_0.txt</code> or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>)</p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="connection.html"><img src="../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../signals2/reference.html#header.boost.signals2.connection_hpp"><img src="../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../index.html"><img src="../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="deconstruct.html"><img src="../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
